package com.pantsdown.engine.ui.activities;

import com.pantsdown.engine.gl.surfaceview.GameGLSurfaceView;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.content.res.Configuration;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;

public class GameActivity extends Activity {

	private GLSurfaceView mGLView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		if(isOpenGLES20Compatible()) {
			mGLView = new GameGLSurfaceView(this);
			setContentView(mGLView);
		} else {
			Log.e("GlEngine", "OpenGL ES 2.0 not supported on this device.  Exiting...");
			finish();
		}
	}

	@Override
	protected void onPause() {
		super.onPause();

		mGLView.onPause();
	}

	@Override
	protected void onResume() {
		super.onResume();

		mGLView.onResume();
	}	

	private boolean isOpenGLES20Compatible() {
		ActivityManager am = 
				(ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
		ConfigurationInfo info = am.getDeviceConfigurationInfo();
		return (info.reqGlEsVersion >= 0x20000);
	}
}
